package com.cosseen.controller;

import com.cosseen.pojo.Brand;
import com.cosseen.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BrandController {

    @Autowired
    BrandService brandService;

    @GetMapping("/allBrand")
    public String queryAllBrand(){
        // 调用service层来查询所有书籍数据
        List<Brand> brands = brandService.queryAllBrand();
        // 为了演示，简单的将其返回字符串
        return brands.toString();
    }

    @GetMapping("/brand/{id}")
    public String queryBrandById(@PathVariable("id") int id){
        Brand brand = brandService.queryById(id);
        return brand.toString();
    }
}
